package com.charlotte.study.gupao.memento.editor;

/**
 * @author junjie.ding
 * @date 2020/3/23
 */
public class Test {

    public static void main(String[] args) {

        DraftsBox box = new DraftsBox();

        // 开始编辑
        Editor editor = new Editor("标题1", "这是标题1的内容", "djj");
        System.out.println("1: " + editor);
        // 保存草稿
        box.addMemento(editor.saveMemento());

        // 继续编辑
        editor.setContent("这是标题1的内容，今天学习了状态模式和备忘录模式");
        System.out.println("2: " + editor);
        // 保存草稿
        box.addMemento(editor.saveMemento());

        // 继续编辑
        editor.setContent("这是标题1的内容，今天学习了状态模式和备忘录模式，吧吧吧吧吧吧吧。。");
        System.out.println("3: " + editor);

        // 出现错误，撤销
        editor.undoMemento(box.getMemento());
        System.out.println("4: " + editor);

        // 还是不对，还想撤销
        editor.undoMemento(box.getMemento());
        System.out.println("5: " + editor);

    }
}
